/**
 * 处理用户查看帖子数据
 */

export const fitlterData = (arr: []) => arr.map((item: any) => item["post"]);
/**
 * 修改属性名称
 */
export const updateParamsName = (
  arr: [],
  labelParam: string,
  valueParam: string
) =>
  arr.map((item) => {
    return { value: item[valueParam], label: item[labelParam] };
  });

/**
 * 节流
 */
export function throttle(func: Function, delay: number) {
  let lastCall = 0;
  return function (...args: any[]) {
    const now = new Date().getTime();
    if (now - lastCall < delay) {
      return;
    }
    lastCall = now;
    return func(...args);
  };
}
/**
 * 检查是否为客户端渲染
 */
export function isClient(): boolean {
  console.log(typeof window);
  return typeof window !== "undefined";
}
